home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Sound / AHI / Developer / examples / Device / AHI-Handler / main.h < prev    next >
C/C++ Source or Header  |  1997-03-12  |  4KB  |  139 lines

  1.  
  2. #include <devices/ahi.h>
  3.  
  4. struct HandlerData {
  5.   BOOL               initialized;    // TRUE if structure initialized, else FALSE
  6.   BOOL               writing;        // TRUE if writing, FALSE otherwise
  7.   UBYTE             *buffer1;        // Address of read buffer
  8.   UBYTE             *buffer2;
  9.   LONG               length;         // Offset to first invalid sample frame
  10.   LONG               offset;         // Current pointer
  11.   struct AHIRequest *readreq;        // IO Request used for reading
  12.   struct AHIRequest *writereq1;      // IO Request used for writing
  13.   struct AHIRequest *writereq2;      // IO Request used for writing
  14.   ULONG              bits;
  15.   ULONG              channels;
  16.   ULONG              type;
  17.   ULONG              freq;
  18.   Fixed              vol;
  19.   sposition          pos;
  20.   LONG               priority;
  21.   LONG               totallength;     // Total number of bytes to play/record
  22.   LONG               buffersize;      // Play/record buffer size
  23.   UBYTE              format;          // See definition below.
  24.  
  25.   struct RDArgs     *rdargs;
  26.   struct RDArgs     *rdargs2;
  27.   struct {
  28.     ULONG           *bits;
  29.     ULONG           *channels;
  30.     ULONG           *freq;
  31.     STRPTR           type;
  32.     Fixed           *volume;
  33.     sposition       *position;
  34.     LONG            *priority;
  35.     LONG            *length;
  36.     LONG            *seconds;
  37.     LONG            *buffersize;
  38.     LONG            *unit;
  39.  
  40.     UWORD            format;
  41.   }                  args;
  42.  
  43. };
  44.  
  45. #define SIGNED   1
  46. #define AIFF     2
  47. #define AIFC     3
  48.  
  49.  
  50. /* AIFF and AIFC defines was taken from Olaf `Olsen' Barthel's AIFF DataType. */
  51.  
  52.     // 80 bit IEEE Standard 754 floating point number
  53.  
  54. typedef struct {
  55.     unsigned short    exponent;        // Exponent, bit #15 is sign bit for mantissa
  56.     unsigned long    mantissa[2];        // 64 bit mantissa
  57. } extended;
  58.  
  59.     // Audio Interchange Format chunk data
  60.  
  61. #define ID_AIFF MAKE_ID('A','I','F','F')
  62. #define ID_AIFC MAKE_ID('A','I','F','C')
  63.  
  64. #define ID_FVER MAKE_ID('F','V','E','R')
  65. #define ID_COMM MAKE_ID('C','O','M','M')
  66. #define ID_SSND MAKE_ID('S','S','N','D')
  67.  
  68.     // "COMM" chunk header
  69.  
  70. typedef struct {
  71.     short        numChannels;        // Number of channels
  72.     unsigned long    numSampleFrames;    // Number of sample frames
  73.     short        sampleSize;        // Number of bits per sample point
  74.     extended    sampleRate;        // Replay rate in samples per second
  75. } CommonChunk;
  76.  
  77.     // The same for "AIFC" type files
  78.  
  79. #define NO_COMPRESSION MAKE_ID('N','O','N','E') // No sound compression
  80.  
  81. typedef struct {
  82.     short        numChannels;        // Number of channels
  83.     unsigned long    numSampleFrames;    // Number of sample frames
  84.     short        sampleSize;        // Number of bits per sample point
  85.     extended    sampleRate;        // Replay rate in samples per second
  86.     unsigned long    compressionType;    // Compression type
  87.     char        compressionName[(sizeof("not compressed")+1)&(~1)];
  88. } ExtCommonChunk;
  89.  
  90.  
  91.     // "SSND" chunk header
  92.  
  93. typedef struct {
  94.     unsigned long    offset,         // Offset to sound data, for block alignment
  95.             blockSize;        // Size of block data is aligned to
  96. } SampledSoundHeader;
  97.  
  98.     // "FVER" chunk header
  99.  
  100. typedef struct {
  101.     long        timestamp;        // Format version creation date
  102. } FormatVersionHeader;
  103.  
  104. #define AIFCVersion1 0xA2805140         // "AIFC" file format version #1
  105.  
  106.  
  107. struct AIFCHeader {
  108.   ULONG                 FORMid;
  109.   ULONG                 FORMsize;
  110.   ULONG                 AIFCid;
  111.  
  112.   ULONG                 FVERid;
  113.   ULONG                 FVERsize;
  114.   FormatVersionHeader   FVERchunk;
  115.  
  116.   ULONG                 COMMid;
  117.   ULONG                 COMMsize;
  118.   ExtCommonChunk        COMMchunk;
  119.  
  120.   ULONG                 SSNDid;
  121.   ULONG                 SSNDsize;
  122.   SampledSoundHeader    SSNDchunk;
  123. };
  124.  
  125. struct AIFFHeader {
  126.   ULONG                 FORMid;
  127.   ULONG                 FORMsize;
  128.   ULONG                 AIFFid;
  129.  
  130.   ULONG                 COMMid;
  131.   ULONG                 COMMsize;
  132.   CommonChunk           COMMchunk;
  133.  
  134.   ULONG                 SSNDid;
  135.   ULONG                 SSNDsize;
  136.   SampledSoundHeader    SSNDchunk;
  137. };
  138.  
  139.